<?php
class UserWeiboRepostSaveAction extends UserAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'json';
	}
	
	public function execute()
	{
		$this->code 	= 0;
		$weibo_id 		= (int)$this->context->post('weibo_id');
		$is_comment_parent 		= (int)$this->context->post('is_comment_parent');
		
		$content 		= $this->context->post('content');
		if (!$content || !$weibo_id)
		{
			$this->code 	= 101;
			return;
		}
		$weiboService	= new WeiboService();
		$weibo 			= $weiboService->get($weibo_id);
		$data = array(
			'content'=>$content,
			'user_id'=>$this->data['user']['id'],
			'parent_id'=>$weibo_id,
		);
		if ($weibo['parent_id']){//转发原作者
			$data['parent_id'] = $weibo['parent_id'];
		}
		if ($weibo && $weiboService->addData($data, $is_comment_parent))
		{
			$this->code = 200;
			$this->message = '亲，转发成功~';
		}
		
	}
}
